<html>
<head>
  <title>../ex5b90.f90</title>
</head>
<body bgcolor="#ffffff" text="#000000">
<a href="../ex5b90.f90">download the original source code</a>.
<pre>
<a name="line1">  1</a> <font color="4444FF">!</font>
<a name="line2">  2</a> <font color="4444FF">!</font>   <font color="#2040a0">Example</font> <font color="#FF0000">5</font>
<a name="line3">  3</a> <font color="4444FF">!</font>
<a name="line4">  4</a> <font color="4444FF">!</font>   <font color="#2040a0">Interface</font><font color="4444FF">:</font>    <font color="#2040a0">Linear</font><font color="4444FF">-</font><font color="#2040a0">Algebraic</font> <font color="4444FF">(</font><font color="#2040a0">IJ</font><font color="4444FF">)</font>, <font color="#2040a0">Babel</font><font color="4444FF">-</font><font color="#2040a0">based</font> <font color="#2040a0">version</font> <font color="#2040a0">in</font> <font color="#2040a0">Fortran90</font>/9<font color="#2040a0">x</font>
<a name="line5">  5</a> <font color="4444FF">!</font>
<a name="line6">  6</a> <font color="4444FF">!</font>   <font color="#2040a0">Compile</font> <font color="#2040a0">with</font><font color="4444FF">:</font> <font color="#2040a0">make</font> <font color="#2040a0">ex5b90</font>
<a name="line7">  7</a> <font color="4444FF">!</font>
<a name="line8">  8</a> <font color="4444FF">!</font>   <font color="#2040a0">Sample</font> <font color="#2040a0">run</font><font color="4444FF">:</font>   <font color="#2040a0">mpirun</font> <font color="4444FF">-</font><font color="#2040a0">np</font> <font color="#FF0000">4</font> <font color="#2040a0">ex5b90</font>
<a name="line9">  9</a> <font color="4444FF">!</font>
<a name="line10"> 10</a> <font color="4444FF">!</font>   <font color="#2040a0">Description</font><font color="4444FF">:</font>  <font color="#2040a0">This</font> <font color="#2040a0">example</font> <font color="#2040a0">solves</font> <font color="#2040a0">the</font> <font color="#FF0000">2</font><font color="4444FF">-</font><font color="#2040a0">D</font>
<a name="line11"> 11</a> <font color="4444FF">!</font>                 <font color="#2040a0">Laplacian</font> <font color="#2040a0">problem</font> <font color="#2040a0">with</font> <font color="#2040a0">zero</font> <font color="#2040a0">boundary</font> <font color="#2040a0">conditions</font>
<a name="line12"> 12</a> <font color="4444FF">!</font>                 <strong>on</strong> <font color="#2040a0">an</font> <font color="#2040a0">nxn</font> <font color="#2040a0">grid</font>.  <font color="#2040a0">The</font> <font color="#2040a0">number</font> <font color="#2040a0">of</font> <font color="#2040a0">unknowns</font> <font color="#2040a0">is</font> <font color="#2040a0">N</font><font color="4444FF">=</font><font color="#2040a0">n</font>^<font color="#FF0000">2</font>.
<a name="line13"> 13</a> <font color="4444FF">!</font>                 <font color="#2040a0">The</font> <font color="#2040a0">standard</font> <font color="#FF0000">5</font><font color="4444FF">-</font><font color="#2040a0">point</font> <font color="#2040a0">stencil</font> <font color="#2040a0">is</font> <font color="#2040a0">used</font>, <font color="#2040a0">and</font> <font color="#2040a0">we</font> <font color="#2040a0">solve</font>
<a name="line14"> 14</a> <font color="4444FF">!</font>                 <font color="#2040a0">for</font> <font color="#2040a0">the</font> <font color="#2040a0">interior</font> <font color="#2040a0">nodes</font> <font color="#2040a0">only</font>.
<a name="line15"> 15</a> <font color="4444FF">!</font>
<a name="line16"> 16</a> <font color="4444FF">!</font>                 <font color="#2040a0">This</font> <font color="#2040a0">example</font> <font color="#2040a0">solves</font> <font color="#2040a0">the</font> <font color="#2040a0">same</font> <font color="#2040a0">problem</font> <font color="#2040a0">as</font> <font color="#2040a0">Example</font> <font color="#FF0000">3</font>.
<a name="line17"> 17</a> <font color="4444FF">!</font>                 <font color="#2040a0">Available</font> <font color="#2040a0">solvers</font> <font color="#2040a0">are</font> <font color="#2040a0">AMG</font>, <font color="#2040a0">PCG</font>, <font color="#2040a0">and</font> <font color="#2040a0">PCG</font> <font color="#2040a0">with</font> <font color="#2040a0">AMG</font> <font color="#2040a0">or</font>
<a name="line18"> 18</a> <font color="4444FF">!</font>                 <font color="#2040a0">Parasails</font> <font color="#2040a0">preconditioners</font>.
<a name="line19"> 19</a> 
<a name="line20"> 20</a> <font color="4444FF">!</font> <font color="#2040a0">HOW</font> <strong>TO</strong> <font color="#2040a0">BUILD</font><font color="4444FF">:</font>
<a name="line21"> 21</a> <font color="4444FF">!</font> <font color="#2040a0">Fortran</font> <font color="#FF0000">90</font> <font color="#2040a0">is</font> <font color="#2040a0">not</font> <font color="#2040a0">yet</font> <font color="#2040a0">fully</font> <font color="#2040a0">supported</font> <font color="#2040a0">by</font> <font color="#2040a0">the</font> <font color="#2040a0">hypre</font> <font color="#2040a0">build</font> <strong>system</strong>, <font color="#2040a0">so</font> <font color="#2040a0">this</font>
<a name="line22"> 22</a> <font color="4444FF">!</font> <font color="#2040a0">is</font> <font color="#2040a0">a</font> <font color="#2040a0">little</font> <font color="#2040a0">more</font> <font color="#2040a0">complicated</font> <font color="#2040a0">than</font> <font color="#2040a0">C</font> <font color="#2040a0">or</font> <font color="#2040a0">Fortran</font> <font color="#FF0000">77</font>.  <font color="#2040a0">These</font> <font color="#2040a0">instructions</font> <font color="#2040a0">have</font>
<a name="line23"> 23</a> <font color="4444FF">!</font> <font color="#2040a0">only</font> <font color="#2040a0">been</font> <font color="#2040a0">tried</font> <font color="#2040a0">in</font> <font color="#2040a0">one</font> <font color="#2040a0">environment</font> <font color="#2040a0">so</font> <font color="#2040a0">far</font>.
<a name="line24"> 24</a> <font color="4444FF">!</font> <font color="#FF0000">1</font>. <font color="#2040a0">Make</font> <font color="#2040a0">sure</font> <font color="#2040a0">you</font> <font color="#2040a0">have</font> <font color="#2040a0">a</font> <font color="#2040a0">Fortran</font> <font color="#FF0000">90</font> <font color="#2040a0">compiler</font><font color="4444FF">!</font>
<a name="line25"> 25</a> <font color="4444FF">!</font> <font color="#FF0000">2</font>. <font color="#2040a0">Make</font> <font color="#2040a0">sure</font> <font color="#2040a0">your</font> <font color="#2040a0">MPI</font> <font color="#2040a0">library</font> <font color="#2040a0">supports</font> <font color="#2040a0">Fortran</font> <font color="#FF0000">90</font>, <font color="#2040a0">true</font> <strong>if</strong> <font color="#2040a0">it</font> <font color="#2040a0">supplies</font> <font color="#2040a0">an</font>
<a name="line26"> 26</a> <font color="4444FF">!</font>    <font color="#2040a0">mpi</font>.<font color="#2040a0">mod</font> <font color="#2040a0">file</font> <font color="#2040a0">and</font> <font color="#2040a0">mpif90</font> <font color="#2040a0">compiler</font><font color="4444FF">-</font><font color="#2040a0">wrapper</font>.
<a name="line27"> 27</a> <font color="4444FF">!</font> <font color="#FF0000">3</font>. <font color="#2040a0">Set</font> <font color="#2040a0">the</font> <font color="#2040a0">environment</font> <font color="#2040a0">variable</font> <font color="#2040a0">FC</font> <strong>to</strong> <font color="#2040a0">your</font> <font color="#2040a0">mpif90</font>, <font color="#2040a0">the</font> <font color="#2040a0">MPI</font> <font color="#2040a0">wrapper</font> <font color="#2040a0">for</font> <font color="#2040a0">your</font>
<a name="line28"> 28</a> <font color="4444FF">!</font>    <font color="#2040a0">Fortran</font> <font color="#FF0000">90</font> <font color="#2040a0">compiler</font>.
<a name="line29"> 29</a> <font color="4444FF">!</font> <font color="#FF0000">4</font>. <font color="#2040a0">Install</font> <font color="#2040a0">Chasm</font>, <font color="#2040a0">which</font> <font color="#2040a0">Babel</font> <font color="#2040a0">requires</font> <font color="#2040a0">for</font> <font color="#2040a0">handling</font> <font color="#2040a0">Fortran</font> <font color="#2040a0">arrays</font>.  <font color="#2040a0">See</font>
<a name="line30"> 30</a> <font color="4444FF">!</font>    <font color="#2040a0">the</font> <font color="#2040a0">Babel</font> <font color="#2040a0">users</font> <font color="#2040a0">manual</font> <font color="#2040a0">for</font> <font color="#2040a0">more</font> <font color="#2040a0">information</font>.
<a name="line31"> 31</a> <font color="4444FF">!</font> <font color="#FF0000">5</font>. <font color="#2040a0">Set</font> <font color="#2040a0">the</font> <font color="#2040a0">environment</font> <font color="#2040a0">variable</font> <font color="#2040a0">CHASMPREFIX</font>, <font color="#2040a0">same</font> <font color="#2040a0">as</font> <font color="#2040a0">your</font> <font color="4444FF">-</font><font color="4444FF">-</font><font color="#2040a0">prefix</font> <font color="#2040a0">option</font>
<a name="line32"> 32</a> <font color="4444FF">!</font>    <font color="#2040a0">in</font> <font color="#2040a0">configuring</font> <font color="#2040a0">Chasm</font>.
<a name="line33"> 33</a> <font color="4444FF">!</font> <font color="#FF0000">6</font>. <font color="#2040a0">Run</font> <font color="#2040a0">hypre</font>'<font color="#2040a0">s</font> '<font color="#2040a0">configure</font> <font color="4444FF">-</font><font color="4444FF">-</font><font color="#2040a0">with</font><font color="4444FF">-</font><font color="#2040a0">babel</font> ...' <font color="#2040a0">and</font> <font color="#2040a0">make</font>.
<a name="line34"> 34</a> <font color="4444FF">!</font> <font color="#FF0000">7</font>. <font color="#2040a0">cd</font> <font color="#2040a0">babel</font>/<font color="#2040a0">bHYPREClient</font><font color="4444FF">-</font><font color="#2040a0">F90</font><font color="4444FF">;</font> <font color="#2040a0">make</font>
<a name="line35"> 35</a> <font color="4444FF">!</font> <font color="#FF0000">8</font>. <font color="#2040a0">cd</font> <font color="#2040a0">examples</font><font color="4444FF">;</font> <font color="#2040a0">make</font> <font color="#2040a0">ex5b90</font>
<a name="line36"> 36</a> 
<a name="line37"> 37</a> 
<a name="line38"> 38</a> <strong>program</strong> <font color="#2040a0">ex5b90</font>
<a name="line39"> 39</a> 
<a name="line40"> 40</a>   <font color="#2040a0">use</font> <font color="#2040a0">mpi</font>
<a name="line41"> 41</a> <font color="4444FF">!</font>  ... <font color="#2040a0">reguires</font> <font color="#2040a0">mpi</font>.<font color="#2040a0">mod</font>, <font color="#2040a0">not</font> <font color="#2040a0">available</font> <font color="4444FF">(</font><font color="#2040a0">I</font> <font color="#2040a0">think</font><font color="4444FF">)</font> <strong>on</strong> <font color="#2040a0">my</font> <font color="#2040a0">machine</font>'<font color="#2040a0">s</font> <font color="4444FF">(</font><font color="#2040a0">public</font><font color="4444FF">)</font> <font color="#2040a0">old</font> <font color="#2040a0">version</font>
<a name="line42"> 42</a> <font color="4444FF">!</font> <font color="#2040a0">of</font> <font color="#2040a0">mpich</font>, <font color="#2040a0">but</font> <font color="#2040a0">works</font> <font color="#2040a0">with</font> <font color="#2040a0">my</font> <font color="#2040a0">private</font> <font color="#2040a0">latest</font> <font color="#2040a0">version</font> <font color="#2040a0">of</font> <font color="#2040a0">OpenMPI</font>.<font color="4444FF">(</font><font color="#2040a0">JfP</font><font color="4444FF">)</font>
<a name="line43"> 43</a> <font color="4444FF">!</font> <strong>If</strong> <font color="#2040a0">a</font> <strong>real</strong> <font color="#2040a0">Fortran</font> <font color="#FF0000">90</font> <font color="#2040a0">mpi</font>.<font color="#2040a0">mod</font> <font color="#2040a0">isn</font>'<font color="#2040a0">t</font> <font color="#2040a0">available</font>, <font color="#2040a0">the</font> <font color="#2040a0">only</font> <font color="#2040a0">alternative</font> <font color="#2040a0">is</font> <strong>to</strong> <strong>include</strong>
<a name="line44"> 44</a> <font color="4444FF">!</font> <font color="#2040a0">the</font> <font color="#2040a0">Fortran</font> <font color="#FF0000">77</font> <font color="#2040a0">one</font>, <font color="#2040a0">plus</font> <font color="#2040a0">corresponding</font> <font color="#2040a0">changes</font> <font color="#2040a0">thereafter</font> ...
<a name="line45"> 45</a> <font color="4444FF">!</font>#<strong>include</strong> <font color="#008000">&quot;mpif.h&quot;</font>
<a name="line46"> 46</a> 
<a name="line47"> 47</a>   <font color="#2040a0">use</font> <font color="#2040a0">sidl_SIDLException</font>
<a name="line48"> 48</a>   <font color="#2040a0">use</font> <font color="#2040a0">bHYPRE_BoomerAMG</font>
<a name="line49"> 49</a>   <font color="#2040a0">use</font> <font color="#2040a0">bHYPRE_MPICommunicator</font>
<a name="line50"> 50</a>   <font color="#2040a0">use</font> <font color="#2040a0">bHYPRE_IJParCSRMatrix</font>
<a name="line51"> 51</a>   <font color="#2040a0">use</font> <font color="#2040a0">bHYPRE_IJParCSRVector</font>
<a name="line52"> 52</a> 
<a name="line53"> 53</a>   <strong>integer</strong>, <strong>parameter</strong><font color="4444FF">:</font><font color="4444FF">:</font>  <font color="#2040a0">MAX_LOCAL_SIZE</font> <font color="4444FF">=</font> <font color="#FF0000">123000</font>
<a name="line54"> 54</a> 
<a name="line55"> 55</a>   <strong>integer</strong>    <font color="#2040a0">ierr</font>, <font color="#2040a0">ierrtmp</font>
<a name="line56"> 56</a>   <strong>integer</strong>    <font color="#2040a0">num_procs</font>, <font color="#2040a0">myid</font>
<a name="line57"> 57</a>   <strong>integer</strong>    <font color="#2040a0">local_size</font>, <font color="#2040a0">extra</font>
<a name="line58"> 58</a>   <strong>integer</strong>    <font color="#2040a0">n</font>, <font color="#2040a0">solver_id</font>, <font color="#2040a0">print_solution</font>, <font color="#2040a0">ng</font>
<a name="line59"> 59</a>   <strong>integer</strong>    <font color="#2040a0">nnz</font>, <font color="#2040a0">ilower</font>, <font color="#2040a0">iupper</font>, <font color="#2040a0">i</font>
<a name="line60"> 60</a>   <strong>real</strong><font color="4444FF">(</font><font color="#FF0000">8</font><font color="4444FF">)</font>    <font color="#2040a0">h</font>, <font color="#2040a0">h2</font>
<a name="line61"> 61</a>   <strong>real</strong><font color="4444FF">(</font><font color="#FF0000">8</font><font color="4444FF">)</font>    <font color="#2040a0">rhs_values</font><font color="4444FF">(</font><font color="#2040a0">MAX_LOCAL_SIZE</font><font color="4444FF">)</font>
<a name="line62"> 62</a>   <strong>real</strong><font color="4444FF">(</font><font color="#FF0000">8</font><font color="4444FF">)</font>    <font color="#2040a0">x_values</font><font color="4444FF">(</font><font color="#2040a0">MAX_LOCAL_SIZE</font><font color="4444FF">)</font>
<a name="line63"> 63</a>   <strong>integer</strong>    <font color="#2040a0">rows</font><font color="4444FF">(</font><font color="#2040a0">MAX_LOCAL_SIZE</font><font color="4444FF">)</font>
<a name="line64"> 64</a>   <strong>integer</strong>    <font color="#2040a0">cols</font><font color="4444FF">(</font><font color="#FF0000">5</font><font color="4444FF">)</font>
<a name="line65"> 65</a>   <strong>real</strong><font color="4444FF">(</font><font color="#FF0000">8</font><font color="4444FF">)</font>    <font color="#2040a0">values</font><font color="4444FF">(</font><font color="#FF0000">5</font><font color="4444FF">)</font>
<a name="line66"> 66</a>   <strong>integer</strong>    <font color="#2040a0">num_iterations</font>
<a name="line67"> 67</a>   <strong>real</strong><font color="4444FF">(</font><font color="#FF0000">8</font><font color="4444FF">)</font>    <font color="#2040a0">final_res_norm</font>, <font color="#2040a0">tol</font>
<a name="line68"> 68</a>   <strong>integer</strong><font color="4444FF">(</font><font color="#FF0000">8</font><font color="4444FF">)</font> <font color="#2040a0">mpi_comm</font>
<a name="line69"> 69</a> 
<a name="line70"> 70</a>   <strong>type</strong><font color="4444FF">(</font><font color="#2040a0">bHYPRE_MPICommunicator_t</font><font color="4444FF">)</font> <font color="#2040a0">bHYPRE_mpicomm</font>
<a name="line71"> 71</a>   <strong>type</strong><font color="4444FF">(</font><font color="#2040a0">bHYPRE_IJParCSRMatrix_t</font><font color="4444FF">)</font>  <font color="#2040a0">parcsr_A</font>
<a name="line72"> 72</a>   <strong>type</strong><font color="4444FF">(</font><font color="#2040a0">bHYPRE_Operator_t</font><font color="4444FF">)</font>        <font color="#2040a0">op_A</font>
<a name="line73"> 73</a>   <strong>type</strong><font color="4444FF">(</font><font color="#2040a0">bHYPRE_IJParCSRVector_t</font><font color="4444FF">)</font>  <font color="#2040a0">par_b</font>
<a name="line74"> 74</a>   <strong>type</strong><font color="4444FF">(</font><font color="#2040a0">bHYPRE_IJParCSRVector_t</font><font color="4444FF">)</font>  <font color="#2040a0">par_x</font>
<a name="line75"> 75</a>   <strong>type</strong><font color="4444FF">(</font><font color="#2040a0">bHYPRE_Vector_t</font><font color="4444FF">)</font>          <font color="#2040a0">vec_b</font>
<a name="line76"> 76</a>   <strong>type</strong><font color="4444FF">(</font><font color="#2040a0">bHYPRE_Vector_t</font><font color="4444FF">)</font>          <font color="#2040a0">vec_x</font>
<a name="line77"> 77</a>   <strong>type</strong><font color="4444FF">(</font><font color="#2040a0">bHYPRE_BoomerAMG_t</font><font color="4444FF">)</font>       <font color="#2040a0">amg_solver</font>
<a name="line78"> 78</a>   <strong>type</strong><font color="4444FF">(</font><font color="#2040a0">sidl_SIDLException_t</font><font color="4444FF">)</font>     <font color="#2040a0">except</font>
<a name="line79"> 79</a>   <font color="4444FF">!</font>     ... <font color="#2040a0">except</font> <font color="#2040a0">is</font> <font color="#2040a0">for</font> <font color="#2040a0">Babel</font> <font color="#2040a0">exceptions</font>, <font color="#2040a0">which</font> <font color="#2040a0">we</font> <font color="#2040a0">shall</font> <font color="#2040a0">ignore</font>
<a name="line80"> 80</a> 
<a name="line81"> 81</a> <font color="4444FF">!</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font>
<a name="line82"> 82</a> <font color="4444FF">!</font>     <font color="#2040a0">Initialize</font> <font color="#2040a0">MPI</font>
<a name="line83"> 83</a> <font color="4444FF">!</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font><font color="4444FF">-</font>
<a name="line84"> 84</a> 
<a name="line85"> 85</a>       <strong>call</strong> <font color="#2040a0">MPI_INIT</font><font color="4444FF">(</font><font color="#2040a0">ierr</font><font color="4444FF">)</font>
<a name="line86"> 86</a>       <strong>call</strong> <font color="#2040a0">MPI_COMM_RANK</font><font color="4444FF">(</font><font color="#2040a0">MPI_COMM_WORLD</font>, <font color="#2040a0">myid</font>, <font color="#2040a0">ierr</font><font color="4444FF">)</font>
<a name="line87"> 87</a>       <strong>call</strong> <font color="#2040a0">MPI_COMM_SIZE</font><font color="4444FF">(</font><font color="#2040a0">MPI_COMM_WORLD</font>, <font color="#2040a0">num_procs</font>, <font color="#2040a0">ierr</font><font color="4444FF">)</font>
<a name="line88"> 88</a>       <font color="#2040a0">mpi_comm</font> <font color="4444FF">=</font> <font color="#2040a0">MPI_COMM_WORLD</font>
<a name="line89"> 89</a>       <strong>call</strong> <font color="#2040a0">bHYPRE_MPICommunicator_CreateF_f</font><font color="4444FF">(</font> <font color="#2040a0">mpi_comm</font>, <font color="#2040a0">bHYPRE_mpicomm</font>, <font color="#2040a0">except</font> <font color="4444FF">)</font>
<a name="line90"> 90</a> 
<a name="line91"> 91</a> <font color="4444FF">!</font>   <font color="#2040a0">Default</font> <font color="#2040a0">problem</font> <font color="#2040a0">parameters</font>
<a name="line92"> 92</a>       <font color="#2040a0">n</font> <font color="4444FF">=</font> <font color="#FF0000">33</font>
<a name="line93"> 93</a>       <font color="#2040a0">solver_id</font> <font color="4444FF">=</font> <font color="#FF0000">0</font>
<a name="line94"> 94</a>       <font color="#2040a0">print_solution</font>  <font color="4444FF">=</font> <font color="#FF0000">0</font>
<a name="line95"> 95</a>       <font color="#2040a0">tol</font> <font color="4444FF">=</font> <font color="#FF0000">1.0d-7</font>
<a name="line96"> 96</a> 
<a name="line97"> 97</a> <font color="4444FF">!</font>   <font color="#2040a0">The</font> <font color="#2040a0">input</font> <font color="#2040a0">section</font> <font color="#2040a0">not</font> <font color="#2040a0">implemented</font> <font color="#2040a0">yet</font>.
<a name="line98"> 98</a> 
<a name="line99"> 99</a> <font color="4444FF">!</font>   <font color="#2040a0">Preliminaries</font><font color="4444FF">:</font> <font color="#2040a0">want</font> <font color="#2040a0">at</font> <font color="#2040a0">least</font> <font color="#2040a0">one</font> <font color="#2040a0">processor</font> <font color="#2040a0">per</font> <font color="#2040a0">row</font>
<a name="line100">100</a>       <strong>if</strong> <font color="4444FF">(</font> <font color="#2040a0">n</font><font color="4444FF">*</font><font color="#2040a0">n</font> .<font color="#2040a0">lt</font>. <font color="#2040a0">num_procs</font><font color="4444FF">)</font> <strong>then</strong>
<a name="line101">101</a>          <font color="#2040a0">n</font> <font color="4444FF">=</font> <font color="#2040a0">int</font><font color="4444FF">(</font><font color="#2040a0">sqrt</font><font color="4444FF">(</font><strong>real</strong><font color="4444FF">(</font><font color="#2040a0">num_procs</font><font color="4444FF">)</font><font color="4444FF">)</font><font color="4444FF">)</font> <font color="4444FF">+</font> <font color="#FF0000">1</font>
<a name="line102">102</a>       <strong>endif</strong>
<a name="line103">103</a> <font color="4444FF">!</font>     <font color="#2040a0">ng</font> <font color="4444FF">=</font> <font color="#2040a0">global</font> <font color="#2040a0">no</font>. <font color="#2040a0">rows</font>, <font color="#2040a0">h</font> <font color="4444FF">=</font> <font color="#2040a0">mesh</font> <font color="#2040a0">size</font>      
<a name="line104">104</a>       <font color="#2040a0">ng</font> <font color="4444FF">=</font> <font color="#2040a0">n</font><font color="4444FF">*</font><font color="#2040a0">n</font>
<a name="line105">105</a>       <font color="#2040a0">h</font> <font color="4444FF">=</font> <font color="#FF0000">1.0d0</font>/<font color="4444FF">(</font><font color="#2040a0">n</font><font color="4444FF">+</font><font color="#FF0000">1</font><font color="4444FF">)</font>
<a name="line106">106</a>       <font color="#2040a0">h2</font> <font color="4444FF">=</font> <font color="#2040a0">h</font><font color="4444FF">*</font><font color="#2040a0">h</font>
<a name="line107">107</a> 
<a name="line108">108</a> <font color="4444FF">!</font>     <font color="#2040a0">Each</font> <font color="#2040a0">processor</font> <font color="#2040a0">knows</font> <font color="#2040a0">only</font> <font color="#2040a0">of</font> <font color="#2040a0">its</font> <font color="#2040a0">own</font> <font color="#2040a0">rows</font> <font color="4444FF">-</font> <font color="#2040a0">the</font> <font color="#2040a0">range</font> <font color="#2040a0">is</font> <font color="#2040a0">denoted</font> <font color="#2040a0">by</font> <font color="#2040a0">ilower</font>
<a name="line109">109</a> <font color="4444FF">!</font>     <font color="#2040a0">and</font> <font color="#2040a0">upper</font>.  <font color="#2040a0">Here</font> <font color="#2040a0">we</font> <font color="#2040a0">partition</font> <font color="#2040a0">the</font> <font color="#2040a0">rows</font>. <font color="#2040a0">We</font> <font color="#2040a0">account</font> <font color="#2040a0">for</font> <font color="#2040a0">the</font> <font color="#2040a0">fact</font> <font color="#2040a0">that</font>
<a name="line110">110</a> <font color="4444FF">!</font>     <font color="#2040a0">N</font> <font color="#2040a0">may</font> <font color="#2040a0">not</font> <font color="#2040a0">divide</font> <font color="#2040a0">evenly</font> <font color="#2040a0">by</font> <font color="#2040a0">the</font> <font color="#2040a0">number</font> <font color="#2040a0">of</font> <font color="#2040a0">processors</font>.
<a name="line111">111</a>       <font color="#2040a0">local_size</font> <font color="4444FF">=</font> <font color="#2040a0">ng</font>/<font color="#2040a0">num_procs</font>
<a name="line112">112</a>       <font color="#2040a0">extra</font> <font color="4444FF">=</font> <font color="#2040a0">ng</font> <font color="4444FF">-</font> <font color="#2040a0">local_size</font><font color="4444FF">*</font><font color="#2040a0">num_procs</font>
<a name="line113">113</a> 
<a name="line114">114</a>       <font color="#2040a0">ilower</font> <font color="4444FF">=</font> <font color="#2040a0">local_size</font><font color="4444FF">*</font><font color="#2040a0">myid</font>
<a name="line115">115</a>       <font color="#2040a0">ilower</font> <font color="4444FF">=</font> <font color="#2040a0">ilower</font> <font color="4444FF">+</font> <font color="#2040a0">min</font><font color="4444FF">(</font><font color="#2040a0">myid</font>, <font color="#2040a0">extra</font><font color="4444FF">)</font>
<a name="line116">116</a> 
<a name="line117">117</a>       <font color="#2040a0">iupper</font> <font color="4444FF">=</font> <font color="#2040a0">local_size</font><font color="4444FF">*</font><font color="4444FF">(</font><font color="#2040a0">myid</font><font color="4444FF">+</font><font color="#FF0000">1</font><font color="4444FF">)</font>
<a name="line118">118</a>       <font color="#2040a0">iupper</font> <font color="4444FF">=</font> <font color="#2040a0">iupper</font> <font color="4444FF">+</font> <font color="#2040a0">min</font><font color="4444FF">(</font><font color="#2040a0">myid</font><font color="4444FF">+</font><font color="#FF0000">1</font>, <font color="#2040a0">extra</font><font color="4444FF">)</font>
<a name="line119">119</a>       <font color="#2040a0">iupper</font> <font color="4444FF">=</font> <font color="#2040a0">iupper</font> <font color="4444FF">-</font> <font color="#FF0000">1</font>
<a name="line120">120</a> 
<a name="line121">121</a> <font color="4444FF">!</font>     <font color="#2040a0">How</font> <font color="#2040a0">many</font> <font color="#2040a0">rows</font> <strong>do</strong> <font color="#2040a0">I</font> <font color="#2040a0">have</font>?
<a name="line122">122</a>       <font color="#2040a0">local_size</font> <font color="4444FF">=</font> <font color="#2040a0">iupper</font> <font color="4444FF">-</font> <font color="#2040a0">ilower</font> <font color="4444FF">+</font> <font color="#FF0000">1</font>
<a name="line123">123</a> 
<a name="line124">124</a> <font color="4444FF">!</font>     <font color="#2040a0">Create</font> <font color="#2040a0">the</font> <font color="#2040a0">matrix</font>.
<a name="line125">125</a> <font color="4444FF">!</font>     <font color="#2040a0">Note</font> <font color="#2040a0">that</font> <font color="#2040a0">this</font> <font color="#2040a0">is</font> <font color="#2040a0">a</font> <font color="#2040a0">square</font> <font color="#2040a0">matrix</font>, <font color="#2040a0">so</font> <font color="#2040a0">we</font> <font color="#2040a0">indicate</font> <font color="#2040a0">the</font> <font color="#2040a0">row</font> <font color="#2040a0">partition</font>
<a name="line126">126</a> <font color="4444FF">!</font>     <font color="#2040a0">size</font> <font color="#2040a0">twice</font> <font color="4444FF">(</font><font color="#2040a0">since</font> <font color="#2040a0">number</font> <font color="#2040a0">of</font> <font color="#2040a0">rows</font> <font color="4444FF">=</font> <font color="#2040a0">number</font> <font color="#2040a0">of</font> <font color="#2040a0">cols</font><font color="4444FF">)</font>
<a name="line127">127</a>       <strong>call</strong> <font color="#2040a0">bHYPRE_IJParCSRMatrix_Create_f</font><font color="4444FF">(</font> <font color="#2040a0">bHYPRE_mpicomm</font>, <font color="#2040a0">ilower</font>, <font color="#2040a0">iupper</font>, <font color="#2040a0">ilower</font>, <font color="#2040a0">iupper</font>, <font color="4444FF">&amp;</font>
<a name="line128">128</a>            <font color="#2040a0">parcsr_A</font>, <font color="#2040a0">except</font> <font color="4444FF">)</font>
<a name="line129">129</a> 
<a name="line130">130</a> <font color="4444FF">!</font>     <font color="#2040a0">op_A</font> <font color="#2040a0">will</font> <font color="#2040a0">be</font> <font color="#2040a0">needed</font> <font color="#2040a0">later</font> <font color="#2040a0">as</font> <font color="#2040a0">a</font> <strong>function</strong> <font color="#2040a0">argument</font>
<a name="line131">131</a>       <strong>call</strong> <font color="#2040a0">bHYPRE_Operator__cast_f</font><font color="4444FF">(</font> <font color="#2040a0">parcsr_A</font>, <font color="#2040a0">op_A</font>, <font color="#2040a0">except</font> <font color="4444FF">)</font>
<a name="line132">132</a> 
<a name="line133">133</a> <font color="4444FF">!</font>     <font color="#2040a0">Choose</font> <font color="#2040a0">a</font> <font color="#2040a0">parallel</font> <font color="#2040a0">csr</font> <strong>format</strong> <font color="#2040a0">storage</font> <font color="4444FF">(</font><font color="#2040a0">see</font> <font color="#2040a0">the</font> <font color="#2040a0">User</font>'<font color="#2040a0">s</font> <font color="#2040a0">Manual</font><font color="4444FF">)</font>
<a name="line134">134</a> <font color="4444FF">!</font>     <font color="#2040a0">Note</font><font color="4444FF">:</font> <font color="#2040a0">Here</font> <font color="#2040a0">the</font> <font color="#2040a0">HYPRE</font> <font color="#2040a0">interface</font> <font color="#2040a0">requires</font> <font color="#2040a0">a</font> <font color="#2040a0">SetObjectType</font> <strong>call</strong>.
<a name="line135">135</a> <font color="4444FF">!</font>     <font color="#2040a0">I</font> <font color="#2040a0">am</font> <font color="#2040a0">using</font> <font color="#2040a0">the</font> <font color="#2040a0">bHYPRE</font> <font color="#2040a0">interface</font> <font color="#2040a0">in</font> <font color="#2040a0">a</font> <font color="#2040a0">way</font> <font color="#2040a0">which</font> <font color="#2040a0">does</font> <font color="#2040a0">not</font> <font color="#2040a0">because</font>
<a name="line136">136</a> <font color="4444FF">!</font>     <font color="#2040a0">the</font> <font color="#2040a0">object</font> <strong>type</strong> <font color="#2040a0">is</font> <font color="#2040a0">already</font> <font color="#2040a0">specified</font> <font color="#2040a0">through</font> <font color="#2040a0">the</font> <font color="#2040a0">class</font> <font color="#2040a0">name</font>.
<a name="line137">137</a> 
<a name="line138">138</a> <font color="4444FF">!</font>     <font color="#2040a0">Initialize</font> <font color="#2040a0">before</font> <font color="#2040a0">setting</font> <font color="#2040a0">coefficients</font>
<a name="line139">139</a>       <strong>call</strong> <font color="#2040a0">bHYPRE_IJParCSRMatrix_Initialize_f</font><font color="4444FF">(</font> <font color="#2040a0">parcsr_A</font>, <font color="#2040a0">ierrtmp</font>, <font color="#2040a0">except</font> <font color="4444FF">)</font>
<a name="line140">140</a> 
<a name="line141">141</a> <font color="4444FF">!</font>     <font color="#2040a0">Now</font> <font color="#2040a0">go</font> <font color="#2040a0">through</font> <font color="#2040a0">my</font> <font color="#2040a0">local</font> <font color="#2040a0">rows</font> <font color="#2040a0">and</font> <font color="#2040a0">set</font> <font color="#2040a0">the</font> <font color="#2040a0">matrix</font> <font color="#2040a0">entries</font>.
<a name="line142">142</a> <font color="4444FF">!</font>     <font color="#2040a0">Each</font> <font color="#2040a0">row</font> <font color="#2040a0">has</font> <font color="#2040a0">at</font> <font color="#2040a0">most</font> <font color="#FF0000">5</font> <font color="#2040a0">entries</font>. <font color="#2040a0">For</font> <font color="#2040a0">example</font>, <strong>if</strong> <font color="#2040a0">n</font><font color="4444FF">=</font><font color="#FF0000">3</font><font color="4444FF">:</font>
<a name="line143">143</a> <font color="4444FF">!</font>
<a name="line144">144</a> <font color="4444FF">!</font>      <font color="#2040a0">A</font> <font color="4444FF">=</font> <font color="4444FF">[</font><font color="#2040a0">M</font> <font color="4444FF">-</font><font color="#2040a0">I</font> <font color="#FF0000">0</font><font color="4444FF">;</font> <font color="4444FF">-</font><font color="#2040a0">I</font> <font color="#2040a0">M</font> <font color="4444FF">-</font><font color="#2040a0">I</font><font color="4444FF">;</font> <font color="#FF0000">0</font> <font color="4444FF">-</font><font color="#2040a0">I</font> <font color="#2040a0">M</font><font color="4444FF">]</font>
<a name="line145">145</a> <font color="4444FF">!</font>      <font color="#2040a0">M</font> <font color="4444FF">=</font> <font color="4444FF">[</font><font color="#FF0000">4</font> <font color="4444FF">-</font><font color="#FF0000">1</font> <font color="#FF0000">0</font><font color="4444FF">;</font> <font color="4444FF">-</font><font color="#FF0000">1</font> <font color="#FF0000">4</font> <font color="4444FF">-</font><font color="#FF0000">1</font><font color="4444FF">;</font> <font color="#FF0000">0</font> <font color="4444FF">-</font><font color="#FF0000">1</font> <font color="#FF0000">4</font><font color="4444FF">]</font>
<a name="line146">146</a> <font color="4444FF">!</font>
<a name="line147">147</a> <font color="4444FF">!</font>     <font color="#2040a0">Note</font> <font color="#2040a0">that</font> <font color="#2040a0">here</font> <font color="#2040a0">we</font> <font color="#2040a0">are</font> <font color="#2040a0">setting</font> <font color="#2040a0">one</font> <font color="#2040a0">row</font> <font color="#2040a0">at</font> <font color="#2040a0">a</font> <font color="#2040a0">time</font>, <font color="#2040a0">though</font>
<a name="line148">148</a> <font color="4444FF">!</font>     <font color="#2040a0">one</font> <font color="#2040a0">could</font> <font color="#2040a0">set</font> <font color="#2040a0">all</font> <font color="#2040a0">the</font> <font color="#2040a0">rows</font> <font color="#2040a0">together</font> <font color="4444FF">(</font><font color="#2040a0">see</font> <font color="#2040a0">the</font> <font color="#2040a0">User</font>'<font color="#2040a0">s</font> <font color="#2040a0">Manual</font><font color="4444FF">)</font>.
<a name="line149">149</a> 
<a name="line150">150</a>       <strong>do</strong> <font color="#2040a0">i</font> <font color="4444FF">=</font> <font color="#2040a0">ilower</font>, <font color="#2040a0">iupper</font>
<a name="line151">151</a>          <font color="#2040a0">nnz</font> <font color="4444FF">=</font> <font color="#FF0000">1</font>
<a name="line152">152</a> 
<a name="line153">153</a> <font color="4444FF">!</font>        <font color="#2040a0">The</font> <font color="#2040a0">left</font> <font color="#2040a0">identity</font> <strong>block</strong><font color="4444FF">:</font><font color="#2040a0">position</font> <font color="#2040a0">i</font><font color="4444FF">-</font><font color="#2040a0">n</font>
<a name="line154">154</a>          <strong>if</strong> <font color="4444FF">(</font> <font color="4444FF">(</font><font color="#2040a0">i</font><font color="4444FF">-</font><font color="#2040a0">n</font><font color="4444FF">)</font> .<font color="#2040a0">ge</font>. <font color="#FF0000">0</font> <font color="4444FF">)</font> <strong>then</strong>
<a name="line155">155</a> 	    <font color="#2040a0">cols</font><font color="4444FF">(</font><font color="#2040a0">nnz</font><font color="4444FF">)</font> <font color="4444FF">=</font> <font color="#2040a0">i</font><font color="4444FF">-</font><font color="#2040a0">n</font>
<a name="line156">156</a> 	    <font color="#2040a0">values</font><font color="4444FF">(</font><font color="#2040a0">nnz</font><font color="4444FF">)</font> <font color="4444FF">=</font> <font color="4444FF">-</font><font color="#FF0000">1.0d0</font>
<a name="line157">157</a> 	    <font color="#2040a0">nnz</font> <font color="4444FF">=</font> <font color="#2040a0">nnz</font> <font color="4444FF">+</font> <font color="#FF0000">1</font>
<a name="line158">158</a>          <strong>endif</strong>
<a name="line159">159</a> 
<a name="line160">160</a> <font color="4444FF">!</font>         <font color="#2040a0">The</font> <font color="#2040a0">left</font> <font color="4444FF">-</font><font color="#FF0000">1</font><font color="4444FF">:</font> <font color="#2040a0">position</font> <font color="#2040a0">i</font><font color="4444FF">-</font><font color="#FF0000">1</font>
<a name="line161">161</a>          <strong>if</strong> <font color="4444FF">(</font> <font color="#2040a0">mod</font><font color="4444FF">(</font><font color="#2040a0">i</font>,<font color="#2040a0">n</font><font color="4444FF">)</font>.<font color="#2040a0">ne</font><font color="#FF0000">.0</font> <font color="4444FF">)</font> <strong>then</strong>
<a name="line162">162</a>             <font color="#2040a0">cols</font><font color="4444FF">(</font><font color="#2040a0">nnz</font><font color="4444FF">)</font> <font color="4444FF">=</font> <font color="#2040a0">i</font><font color="4444FF">-</font><font color="#FF0000">1</font>
<a name="line163">163</a>             <font color="#2040a0">values</font><font color="4444FF">(</font><font color="#2040a0">nnz</font><font color="4444FF">)</font> <font color="4444FF">=</font> <font color="4444FF">-</font><font color="#FF0000">1.0d0</font>
<a name="line164">164</a>             <font color="#2040a0">nnz</font> <font color="4444FF">=</font> <font color="#2040a0">nnz</font> <font color="4444FF">+</font> <font color="#FF0000">1</font>
<a name="line165">165</a>          <strong>endif</strong>
<a name="line166">166</a> 
<a name="line167">167</a> <font color="4444FF">!</font>        <font color="#2040a0">Set</font> <font color="#2040a0">the</font> <font color="#2040a0">diagonal</font><font color="4444FF">:</font> <font color="#2040a0">position</font> <font color="#2040a0">i</font>
<a name="line168">168</a>          <font color="#2040a0">cols</font><font color="4444FF">(</font><font color="#2040a0">nnz</font><font color="4444FF">)</font> <font color="4444FF">=</font> <font color="#2040a0">i</font>
<a name="line169">169</a>          <font color="#2040a0">values</font><font color="4444FF">(</font><font color="#2040a0">nnz</font><font color="4444FF">)</font> <font color="4444FF">=</font> <font color="#FF0000">4.0d0</font>
<a name="line170">170</a>          <font color="#2040a0">nnz</font> <font color="4444FF">=</font> <font color="#2040a0">nnz</font> <font color="4444FF">+</font> <font color="#FF0000">1</font>
<a name="line171">171</a> 
<a name="line172">172</a> <font color="4444FF">!</font>        <font color="#2040a0">The</font> <font color="#2040a0">right</font> <font color="4444FF">-</font><font color="#FF0000">1</font><font color="4444FF">:</font> <font color="#2040a0">position</font> <font color="#2040a0">i</font><font color="4444FF">+</font><font color="#FF0000">1</font>
<a name="line173">173</a>          <strong>if</strong> <font color="4444FF">(</font> <font color="#2040a0">mod</font><font color="4444FF">(</font><font color="4444FF">(</font><font color="#2040a0">i</font><font color="4444FF">+</font><font color="#FF0000">1</font><font color="4444FF">)</font>,<font color="#2040a0">n</font><font color="4444FF">)</font> .<font color="#2040a0">ne</font>. <font color="#FF0000">0</font> <font color="4444FF">)</font> <strong>then</strong>
<a name="line174">174</a>             <font color="#2040a0">cols</font><font color="4444FF">(</font><font color="#2040a0">nnz</font><font color="4444FF">)</font> <font color="4444FF">=</font> <font color="#2040a0">i</font><font color="4444FF">+</font><font color="#FF0000">1</font>
<a name="line175">175</a>             <font color="#2040a0">values</font><font color="4444FF">(</font><font color="#2040a0">nnz</font><font color="4444FF">)</font> <font color="4444FF">=</font> <font color="4444FF">-</font><font color="#FF0000">1.0d0</font>
<a name="line176">176</a>             <font color="#2040a0">nnz</font> <font color="4444FF">=</font> <font color="#2040a0">nnz</font> <font color="4444FF">+</font> <font color="#FF0000">1</font>
<a name="line177">177</a>          <strong>endif</strong>
<a name="line178">178</a> 
<a name="line179">179</a> <font color="4444FF">!</font>        <font color="#2040a0">The</font> <font color="#2040a0">right</font> <font color="#2040a0">identity</font> <strong>block</strong><font color="4444FF">:</font><font color="#2040a0">position</font> <font color="#2040a0">i</font><font color="4444FF">+</font><font color="#2040a0">n</font>
<a name="line180">180</a>          <strong>if</strong> <font color="4444FF">(</font><font color="4444FF">(</font><font color="#2040a0">i</font><font color="4444FF">+</font><font color="#2040a0">n</font><font color="4444FF">)</font> .<font color="#2040a0">lt</font>. <font color="#2040a0">ng</font> <font color="4444FF">)</font> <strong>then</strong>
<a name="line181">181</a>             <font color="#2040a0">cols</font><font color="4444FF">(</font><font color="#2040a0">nnz</font><font color="4444FF">)</font> <font color="4444FF">=</font> <font color="#2040a0">i</font><font color="4444FF">+</font><font color="#2040a0">n</font>
<a name="line182">182</a>             <font color="#2040a0">values</font><font color="4444FF">(</font><font color="#2040a0">nnz</font><font color="4444FF">)</font> <font color="4444FF">=</font> <font color="4444FF">-</font><font color="#FF0000">1.0d0</font>
<a name="line183">183</a>             <font color="#2040a0">nnz</font> <font color="4444FF">=</font> <font color="#2040a0">nnz</font> <font color="4444FF">+</font> <font color="#FF0000">1</font>
<a name="line184">184</a>          <strong>endif</strong>
<a name="line185">185</a> 
<a name="line186">186</a> <font color="4444FF">!</font>        <font color="#2040a0">Set</font> <font color="#2040a0">the</font> <font color="#2040a0">values</font> <font color="#2040a0">for</font> <font color="#2040a0">row</font> <font color="#2040a0">i</font>
<a name="line187">187</a>          <strong>call</strong> <font color="#2040a0">bHYPRE_IJParCSRMatrix_SetValues_f</font><font color="4444FF">(</font> <font color="#2040a0">parcsr_A</font>, <font color="#FF0000">1</font>, <font color="#2040a0">nnz</font><font color="4444FF">-</font><font color="#FF0000">1</font>, <font color="#2040a0">i</font>, <font color="#2040a0">cols</font>, <font color="#2040a0">values</font>, <font color="#FF0000">5</font>, <font color="4444FF">&amp;</font>
<a name="line188">188</a>               <font color="#2040a0">ierrtmp</font>, <font color="#2040a0">except</font> <font color="4444FF">)</font>
<a name="line189">189</a> 
<a name="line190">190</a>       <font color="#2040a0">enddo</font>
<a name="line191">191</a> 
<a name="line192">192</a> <font color="4444FF">!</font>     <font color="#2040a0">Assemble</font> <font color="#2040a0">after</font> <font color="#2040a0">setting</font> <font color="#2040a0">the</font> <font color="#2040a0">coefficients</font>
<a name="line193">193</a>       <strong>call</strong> <font color="#2040a0">bHYPRE_IJParCSRMatrix_Assemble_f</font><font color="4444FF">(</font> <font color="#2040a0">parcsr_A</font>, <font color="#2040a0">ierrtmp</font>, <font color="#2040a0">except</font> <font color="4444FF">)</font>
<a name="line194">194</a> 
<a name="line195">195</a> <font color="4444FF">!</font>     <font color="#2040a0">Create</font> <font color="#2040a0">the</font> <font color="#2040a0">rhs</font> <font color="#2040a0">and</font> <font color="#2040a0">solution</font>
<a name="line196">196</a>       <strong>call</strong> <font color="#2040a0">bHYPRE_IJParCSRVector_Create_f</font><font color="4444FF">(</font> <font color="#2040a0">bHYPRE_mpicomm</font>, <font color="#2040a0">ilower</font>, <font color="#2040a0">iupper</font>, <font color="#2040a0">par_b</font>, <font color="#2040a0">except</font> <font color="4444FF">)</font>
<a name="line197">197</a> <font color="4444FF">!</font>     <font color="#2040a0">vec_b</font> <font color="#2040a0">will</font> <font color="#2040a0">be</font> <font color="#2040a0">needed</font> <font color="#2040a0">later</font> <font color="#2040a0">for</font> <strong>function</strong> <font color="#2040a0">arguments</font>
<a name="line198">198</a>       <strong>call</strong> <font color="#2040a0">bHYPRE_Vector__cast_f</font><font color="4444FF">(</font> <font color="#2040a0">par_b</font>, <font color="#2040a0">vec_b</font>, <font color="#2040a0">except</font> <font color="4444FF">)</font>
<a name="line199">199</a> 
<a name="line200">200</a>       <strong>call</strong> <font color="#2040a0">bHYPRE_IJParCSRVector_Initialize_f</font><font color="4444FF">(</font> <font color="#2040a0">par_b</font>, <font color="#2040a0">ierrtmp</font>, <font color="#2040a0">except</font> <font color="4444FF">)</font>
<a name="line201">201</a> 
<a name="line202">202</a>       <strong>call</strong> <font color="#2040a0">bHYPRE_IJParCSRVector_Create_f</font><font color="4444FF">(</font> <font color="#2040a0">bHYPRE_mpicomm</font>, <font color="#2040a0">ilower</font>, <font color="#2040a0">iupper</font>, <font color="#2040a0">par_x</font>, <font color="#2040a0">except</font> <font color="4444FF">)</font>
<a name="line203">203</a> <font color="4444FF">!</font>     <font color="#2040a0">vec_x</font> <font color="#2040a0">will</font> <font color="#2040a0">be</font> <font color="#2040a0">needed</font> <font color="#2040a0">later</font> <font color="#2040a0">for</font> <strong>function</strong> <font color="#2040a0">arguments</font>
<a name="line204">204</a>       <strong>call</strong> <font color="#2040a0">bHYPRE_Vector__cast_f</font><font color="4444FF">(</font> <font color="#2040a0">par_x</font>, <font color="#2040a0">vec_x</font>, <font color="#2040a0">except</font> <font color="4444FF">)</font>
<a name="line205">205</a> 
<a name="line206">206</a>       <strong>call</strong> <font color="#2040a0">bHYPRE_IJParCSRVector_Initialize_f</font><font color="4444FF">(</font> <font color="#2040a0">par_x</font>, <font color="#2040a0">ierrtmp</font>, <font color="#2040a0">except</font> <font color="4444FF">)</font>
<a name="line207">207</a> 
<a name="line208">208</a> <font color="4444FF">!</font>     <font color="#2040a0">Set</font> <font color="#2040a0">the</font> <font color="#2040a0">rhs</font> <font color="#2040a0">values</font> <strong>to</strong> <font color="#2040a0">h</font>^<font color="#FF0000">2</font> <font color="#2040a0">and</font> <font color="#2040a0">the</font> <font color="#2040a0">solution</font> <strong>to</strong> <font color="#2040a0">zero</font>
<a name="line209">209</a>       <strong>do</strong> <font color="#2040a0">i</font> <font color="4444FF">=</font> <font color="#FF0000">1</font>, <font color="#2040a0">local_size</font>
<a name="line210">210</a>          <font color="#2040a0">rhs_values</font><font color="4444FF">(</font><font color="#2040a0">i</font><font color="4444FF">)</font> <font color="4444FF">=</font> <font color="#2040a0">h2</font>
<a name="line211">211</a>          <font color="#2040a0">x_values</font><font color="4444FF">(</font><font color="#2040a0">i</font><font color="4444FF">)</font> <font color="4444FF">=</font> <font color="#FF0000">0.0</font>
<a name="line212">212</a>          <font color="#2040a0">rows</font><font color="4444FF">(</font><font color="#2040a0">i</font><font color="4444FF">)</font> <font color="4444FF">=</font> <font color="#2040a0">ilower</font> <font color="4444FF">+</font> <font color="#2040a0">i</font> <font color="4444FF">-</font><font color="#FF0000">1</font>
<a name="line213">213</a>       <font color="#2040a0">enddo</font>
<a name="line214">214</a>       <strong>call</strong> <font color="#2040a0">bHYPRE_IJParCSRVector_SetValues_f</font><font color="4444FF">(</font> <font color="#2040a0">par_b</font>, <font color="#2040a0">local_size</font>, <font color="#2040a0">rows</font>, <font color="#2040a0">rhs_values</font>, <font color="4444FF">&amp;</font>
<a name="line215">215</a>            <font color="#2040a0">ierrtmp</font>, <font color="#2040a0">except</font> <font color="4444FF">)</font>
<a name="line216">216</a>       <strong>call</strong> <font color="#2040a0">bHYPRE_IJParCSRVector_SetValues_f</font><font color="4444FF">(</font> <font color="#2040a0">par_x</font>, <font color="#2040a0">local_size</font>, <font color="#2040a0">rows</font>, <font color="#2040a0">x_values</font>, <font color="#2040a0">ierrtmp</font>, <font color="#2040a0">except</font> <font color="4444FF">)</font>
<a name="line217">217</a> 
<a name="line218">218</a> 
<a name="line219">219</a>       <strong>call</strong> <font color="#2040a0">bHYPRE_IJParCSRVector_Assemble_f</font><font color="4444FF">(</font> <font color="#2040a0">par_b</font>, <font color="#2040a0">ierrtmp</font>, <font color="#2040a0">except</font> <font color="4444FF">)</font>
<a name="line220">220</a>       <strong>call</strong> <font color="#2040a0">bHYPRE_IJParCSRVector_Assemble_f</font><font color="4444FF">(</font> <font color="#2040a0">par_x</font>, <font color="#2040a0">ierrtmp</font>, <font color="#2040a0">except</font> <font color="4444FF">)</font>
<a name="line221">221</a> 
<a name="line222">222</a> <font color="4444FF">!</font>     <font color="#2040a0">Choose</font> <font color="#2040a0">a</font> <font color="#2040a0">solver</font> <font color="#2040a0">and</font> <font color="#2040a0">solve</font> <font color="#2040a0">the</font> <strong>system</strong>
<a name="line223">223</a> 
<a name="line224">224</a> <font color="4444FF">!</font>      <font color="#2040a0">AMG</font>
<a name="line225">225</a>       <strong>if</strong> <font color="4444FF">(</font> <font color="#2040a0">solver_id</font> <font color="4444FF">=</font><font color="4444FF">=</font> <font color="#FF0000">0</font> <font color="4444FF">)</font> <strong>then</strong>
<a name="line226">226</a> 
<a name="line227">227</a> <font color="4444FF">!</font>        <font color="#2040a0">Create</font> <font color="#2040a0">solver</font>
<a name="line228">228</a>          <strong>call</strong> <font color="#2040a0">bHYPRE_BoomerAMG_Create_f</font><font color="4444FF">(</font> <font color="#2040a0">bHYPRE_mpicomm</font>, <font color="#2040a0">parcsr_A</font>, <font color="#2040a0">amg_solver</font>, <font color="#2040a0">except</font> <font color="4444FF">)</font>
<a name="line229">229</a> 
<a name="line230">230</a> <font color="4444FF">!</font>        <font color="#2040a0">Set</font> <font color="#2040a0">some</font> <font color="#2040a0">parameters</font> <font color="4444FF">(</font><font color="#2040a0">See</font> <font color="#2040a0">Reference</font> <font color="#2040a0">Manual</font> <font color="#2040a0">for</font> <font color="#2040a0">more</font> <font color="#2040a0">parameters</font><font color="4444FF">)</font>
<a name="line231">231</a> <font color="4444FF">!</font>        <font color="#2040a0">PrintLevel</font><font color="4444FF">=</font><font color="#FF0000">3</font> <font color="#2040a0">means</font> <strong>print</strong> <font color="#2040a0">solve</font> <font color="#2040a0">info</font> <font color="4444FF">+</font> <font color="#2040a0">parameters</font>
<a name="line232">232</a> <font color="4444FF">!</font>        <font color="#2040a0">CoarsenType</font><font color="4444FF">=</font><font color="#FF0000">6</font> <font color="#2040a0">means</font> <font color="#2040a0">Falgout</font> <font color="#2040a0">coarsening</font>
<a name="line233">233</a> <font color="4444FF">!</font>        <font color="#2040a0">RelaxType</font><font color="4444FF">=</font><font color="#FF0000">3</font> <font color="#2040a0">means</font> <font color="#2040a0">Gauss</font><font color="4444FF">-</font><font color="#2040a0">Seidel</font>/<font color="#2040a0">Jacobi</font> <font color="#2040a0">hybrid</font> <font color="#2040a0">relaxation</font>
<a name="line234">234</a>          <strong>call</strong> <font color="#2040a0">bHYPRE_BoomerAMG_SetIntParameter_f</font><font color="4444FF">(</font> <font color="#2040a0">amg_solver</font>, <font color="#008000">&quot;PrintLevel&quot;</font>, <font color="#FF0000">3</font>, <font color="#2040a0">ierrtmp</font>, <font color="#2040a0">except</font> <font color="4444FF">)</font>
<a name="line235">235</a>          <strong>call</strong> <font color="#2040a0">bHYPRE_BoomerAMG_SetIntParameter_f</font><font color="4444FF">(</font> <font color="#2040a0">amg_solver</font>, <font color="#008000">&quot;CoarsenType&quot;</font>, <font color="#FF0000">6</font>, <font color="#2040a0">ierrtmp</font>, <font color="#2040a0">except</font> <font color="4444FF">)</font>
<a name="line236">236</a>          <strong>call</strong> <font color="#2040a0">bHYPRE_BoomerAMG_SetIntParameter_f</font><font color="4444FF">(</font> <font color="#2040a0">amg_solver</font>, <font color="#008000">&quot;RelaxType&quot;</font>, <font color="#FF0000">3</font>, <font color="#2040a0">ierrtmp</font>, <font color="#2040a0">except</font> <font color="4444FF">)</font>
<a name="line237">237</a>          <strong>call</strong> <font color="#2040a0">bHYPRE_BoomerAMG_SetIntParameter_f</font><font color="4444FF">(</font> <font color="#2040a0">amg_solver</font>, <font color="#008000">&quot;NumSweeps&quot;</font>, <font color="#FF0000">1</font>, <font color="#2040a0">ierrtmp</font>, <font color="#2040a0">except</font> <font color="4444FF">)</font>
<a name="line238">238</a>          <strong>call</strong> <font color="#2040a0">bHYPRE_BoomerAMG_SetIntParameter_f</font><font color="4444FF">(</font> <font color="#2040a0">amg_solver</font>, <font color="#008000">&quot;MaxLevels&quot;</font>, <font color="#FF0000">20</font>, <font color="#2040a0">ierrtmp</font>, <font color="#2040a0">except</font> <font color="4444FF">)</font>
<a name="line239">239</a>          <strong>call</strong> <font color="#2040a0">bHYPRE_BoomerAMG_SetDoubleParameter_f</font><font color="4444FF">(</font> <font color="#2040a0">amg_solver</font>, <font color="#008000">&quot;Tolerance&quot;</font>, <font color="#2040a0">tol</font>, <font color="#2040a0">ierrtmp</font>, <font color="4444FF">&amp;</font>
<a name="line240">240</a>               <font color="#2040a0">except</font> <font color="4444FF">)</font>
<a name="line241">241</a> 
<a name="line242">242</a> <font color="4444FF">!</font>        <font color="#2040a0">Now</font> <font color="#2040a0">setup</font> <font color="#2040a0">and</font> <font color="#2040a0">solve</font><font color="4444FF">!</font>
<a name="line243">243</a>          <strong>call</strong> <font color="#2040a0">bHYPRE_BoomerAMG_Setup_f</font><font color="4444FF">(</font> <font color="#2040a0">amg_solver</font>, <font color="#2040a0">vec_b</font>, <font color="#2040a0">vec_x</font>, <font color="#2040a0">ierrtmp</font>, <font color="#2040a0">except</font> <font color="4444FF">)</font>
<a name="line244">244</a>          <strong>call</strong> <font color="#2040a0">bHYPRE_BoomerAMG_Apply_f</font><font color="4444FF">(</font> <font color="#2040a0">amg_solver</font>, <font color="#2040a0">vec_b</font>, <font color="#2040a0">vec_x</font>, <font color="#2040a0">ierrtmp</font>, <font color="#2040a0">except</font> <font color="4444FF">)</font>
<a name="line245">245</a> 
<a name="line246">246</a> <font color="4444FF">!</font>        <font color="#2040a0">Run</font> <font color="#2040a0">info</font> <font color="4444FF">-</font> <font color="#2040a0">needed</font> <font color="#2040a0">logging</font> <font color="#2040a0">turned</font> <strong>on</strong> 
<a name="line247">247</a>          <strong>call</strong> <font color="#2040a0">bHYPRE_BoomerAMG_GetIntValue_f</font><font color="4444FF">(</font> <font color="#2040a0">amg_solver</font>, <font color="#008000">&quot;NumIterations&quot;</font>, <font color="#2040a0">num_iterations</font>, <font color="4444FF">&amp;</font>
<a name="line248">248</a>               <font color="#2040a0">ierrtmp</font>, <font color="#2040a0">except</font> <font color="4444FF">)</font>
<a name="line249">249</a>          <font color="#2040a0">ierr</font> <font color="4444FF">=</font> <font color="#2040a0">ierr</font> <font color="4444FF">+</font> <font color="#2040a0">ierrtmp</font>
<a name="line250">250</a>          <strong>call</strong> <font color="#2040a0">bHYPRE_BoomerAMG_GetDoubleValue_f</font><font color="4444FF">(</font> <font color="#2040a0">amg_solver</font>, <font color="#008000">&quot;RelResidualNorm&quot;</font>, <font color="#2040a0">final_res_norm</font>, <font color="4444FF">&amp;</font>
<a name="line251">251</a>               <font color="#2040a0">ierrtmp</font>, <font color="#2040a0">except</font> <font color="4444FF">)</font>
<a name="line252">252</a> 
<a name="line253">253</a>       <strong>if</strong> <font color="4444FF">(</font><font color="#2040a0">myid</font> .<font color="#2040a0">eq</font>. <font color="#FF0000">0</font><font color="4444FF">)</font> <strong>then</strong>
<a name="line254">254</a>          <strong>print</strong> <font color="4444FF">*</font>
<a name="line255">255</a>          <strong>print</strong> <font color="4444FF">*</font>, <font color="#008000">&quot;Iterations = &quot;</font>, <font color="#2040a0">num_iterations</font>
<a name="line256">256</a>          <strong>print</strong> <font color="4444FF">*</font>, <font color="#008000">&quot;Final Relative Residual Norm = &quot;</font>, <font color="#2040a0">final_res_norm</font>
<a name="line257">257</a>          <strong>print</strong> <font color="4444FF">*</font>
<a name="line258">258</a>       <strong>endif</strong>
<a name="line259">259</a> 
<a name="line260">260</a> <font color="4444FF">!</font>     <font color="#2040a0">Destroy</font> <font color="#2040a0">solver</font>
<a name="line261">261</a>       <strong>call</strong> <font color="#2040a0">bHYPRE_BoomerAMG_deleteRef_f</font><font color="4444FF">(</font> <font color="#2040a0">amg_solver</font>, <font color="#2040a0">except</font> <font color="4444FF">)</font>
<a name="line262">262</a> 
<a name="line263">263</a>       <strong>endif</strong>
<a name="line264">264</a> 
<a name="line265">265</a> <font color="4444FF">!</font>     <font color="#2040a0">The</font> <font color="#2040a0">calls</font> <font color="#2040a0">of</font> <font color="#2040a0">other</font> <font color="#2040a0">solvers</font> <font color="#2040a0">are</font> <font color="#2040a0">not</font> <font color="#2040a0">implemented</font> <font color="#2040a0">yet</font>.
<a name="line266">266</a> 
<a name="line267">267</a> 
<a name="line268">268</a> <font color="4444FF">!</font>     <strong>Print</strong> <font color="#2040a0">the</font> <font color="#2040a0">solution</font>
<a name="line269">269</a>       <strong>if</strong> <font color="4444FF">(</font> <font color="#2040a0">print_solution</font> .<font color="#2040a0">ne</font>. <font color="#FF0000">0</font> <font color="4444FF">)</font> <strong>then</strong>
<a name="line270">270</a>          <strong>call</strong> <font color="#2040a0">bHYPRE_IJParCSRVector_Print_f</font><font color="4444FF">(</font> <font color="#2040a0">par_x</font>, <font color="#008000">&quot;ij.out.x&quot;</font>, <font color="#2040a0">except</font> <font color="4444FF">)</font>
<a name="line271">271</a>       <strong>endif</strong>
<a name="line272">272</a> 
<a name="line273">273</a> <font color="4444FF">!</font>     <font color="#2040a0">Clean</font> <font color="#2040a0">up</font>
<a name="line274">274</a>       <strong>call</strong> <font color="#2040a0">bHYPRE_Operator_deleteRef_f</font><font color="4444FF">(</font> <font color="#2040a0">op_A</font>, <font color="#2040a0">except</font> <font color="4444FF">)</font>
<a name="line275">275</a>       <strong>call</strong> <font color="#2040a0">bHYPRE_Vector_deleteRef_f</font><font color="4444FF">(</font> <font color="#2040a0">vec_b</font>, <font color="#2040a0">except</font> <font color="4444FF">)</font>
<a name="line276">276</a>       <strong>call</strong> <font color="#2040a0">bHYPRE_Vector_deleteRef_f</font><font color="4444FF">(</font> <font color="#2040a0">vec_x</font>, <font color="#2040a0">except</font> <font color="4444FF">)</font>
<a name="line277">277</a>       <strong>call</strong> <font color="#2040a0">bHYPRE_IJParCSRMatrix_deleteRef_f</font><font color="4444FF">(</font> <font color="#2040a0">parcsr_A</font>, <font color="#2040a0">except</font> <font color="4444FF">)</font>
<a name="line278">278</a>       <strong>call</strong> <font color="#2040a0">bHYPRE_IJParCSRVector_deleteRef_f</font><font color="4444FF">(</font> <font color="#2040a0">par_b</font>, <font color="#2040a0">except</font> <font color="4444FF">)</font>
<a name="line279">279</a>       <strong>call</strong> <font color="#2040a0">bHYPRE_IJParCSRVector_deleteRef_f</font><font color="4444FF">(</font> <font color="#2040a0">par_x</font>, <font color="#2040a0">except</font> <font color="4444FF">)</font>
<a name="line280">280</a>       <strong>call</strong> <font color="#2040a0">bHYPRE_MPICommunicator_deleteRef_f</font><font color="4444FF">(</font> <font color="#2040a0">bHYPRE_mpicomm</font>, <font color="#2040a0">except</font> <font color="4444FF">)</font>
<a name="line281">281</a> 
<a name="line282">282</a> <font color="4444FF">!</font>     <font color="#2040a0">We</font> <font color="#2040a0">need</font> <font color="#2040a0">a</font> <font color="#2040a0">multi</font><font color="4444FF">-</font><font color="#2040a0">language</font> <font color="#2040a0">equivalent</font> <font color="#2040a0">of</font> <font color="#2040a0">hypre_assert</font>.
<a name="line283">283</a>       <strong>if</strong> <font color="4444FF">(</font> <font color="#2040a0">ierr</font> .<font color="#2040a0">ne</font>. <font color="#FF0000">0</font> <font color="4444FF">)</font> <strong>then</strong>
<a name="line284">284</a>          <strong>print</strong> <font color="4444FF">*</font>
<a name="line285">285</a>          <strong>print</strong> <font color="4444FF">*</font>, <font color="#008000">&quot;***** Bad ierr = &quot;</font>, <font color="#2040a0">ierr</font>
<a name="line286">286</a>          <strong>print</strong> <font color="4444FF">*</font>
<a name="line287">287</a>       <strong>endif</strong>
<a name="line288">288</a> 
<a name="line289">289</a> <font color="4444FF">!</font>     <font color="#2040a0">Finalize</font> <font color="#2040a0">MPI</font>
<a name="line290">290</a>       <strong>call</strong> <font color="#2040a0">MPI_Finalize</font><font color="4444FF">(</font><font color="#2040a0">ierrtmp</font><font color="4444FF">)</font>
<a name="line291">291</a> 
<a name="line292">292</a>       <strong>stop</strong>
<a name="line293">293</a>       <strong>end</strong>

</pre>
<hr>
syntax highlighted by <a href="http://www.palfrader.org/code2html">Code2HTML</a>, v. 0.9.1
</body>
</html>
